package cn.edu.gzgs.entity;

import cn.edu.gzgs.constant.LoginStatus;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.time.LocalDateTime;

@TableName("login_log")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LoginLog {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private String usernameOrUserNo; // 尝试登录的用户名或工号

    private Long userId; // 如果登录成功，记录用户ID

    private String ipAddress; // 登录IP地址

    private LoginStatus loginStatus; // 登录状态

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime attemptTime; // 尝试登录时间

    private String remarks; // 备注，例如 "密码错误", "异地登录风险"

    private String userAgent; // 浏览器或客户端信息

}
